package com.pesking.core.sqlparser;

import java.math.BigDecimal;
import java.util.Map;

import com.pesking.core.parameter.Parameter;
import com.pesking.core.util.LinkedCaseInsensitiveMap;

public class MapListSqlResult extends ListSqlResult<Map<String, String>> {

	public MapListSqlResult(Parameter requestParameter) {
		super(requestParameter);
	}

	@Override
	protected Map<String, String> newRecord() {
		return new LinkedCaseInsensitiveMap<>();
	}

	@Override
	protected void setColumnValue(String columnName, Object columnValue) {
		String rtn = null;
		if (columnValue instanceof BigDecimal) {
			rtn = ((BigDecimal)columnValue).toPlainString();
		}
		else if (columnValue instanceof Double) {
			Double dbl = (Double)columnValue;
			BigDecimal bigDecimal = new BigDecimal(dbl);
			rtn = bigDecimal.toPlainString();
		}
		else {
			rtn = columnValue != null ? columnValue.toString() : null;
		}
		this.row.put(columnName, rtn);
	}

	
}
